<template src="./index.html"></template>

<script>
import DoctorService from "../../../_services/doctor.service";
import hospitalService from "../../../_services/hospital.service";
export default {
  name: "TianDingPatientReservationComponent",
  data() {
    return {
      doctorList: []
    };
  },
  mounted() {
    this.getDoctorInfolList();
  },
  methods: {
    getDoctorInfolList() {
      this.indicator$.open("正在加载...");
      this.doctorList = [];
      let params = {};
      params.pageIndex = 1;
      params.pageSize = 100;
      params.orderby = "RegisterTime";
      params.isDesc = true;
      DoctorService.getDoctorInfolList(params).then(response => {
        if (response && response.Data) {
          response.Data.Items.forEach(item => {
            let temp = this.utils$.dataFormat(item);
            if (temp.AuditStatus === 2) {
              this.getHospitalListByDoctor(temp);
            }
          });
        }
        this.indicator$.close();
      });
    },
    getHospitalListByDoctor(data) {
      let params = {};
      params.doctorID = data.DoctorID;
      hospitalService.getHospitalListByDoctor(params).then(response => {
        if (response && response.Data) {
          data.HospitalName = response.Data[0].HospitalName;
          this.doctorList.push(data);
        }
      });
    },
    routeDetail(params) {
      this.local$.removeItem("tdPatientReservationParams");
      this.local$.setItem("tdPatientReservationParams", JSON.stringify(params));
      this.$router.push({ name: "tdPatientReservationDetail" });
    }
  }
};
</script>
